<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta content="telephone=no" name="format-detection" />
    <!-- 留作将来统一添加 -->
    <TEMPLATE>${TEMPLATE}</TEMPLATE>
    <title>模板html</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/index.css">
    <link rel="stylesheet" type="text/css" href="../../css/data-flex.min.css">
    <style type="text/css">
        .item {
            height: 40px;
            padding: 0 15px;
            border-bottom: 1px solid #e4e4e4;
        }
    </style>
</head>
<body>
    <div class="vueApp" v-cloak>
        <header></header>
        <div v-for="item,index in listData" class="item" @click="handleItem(item)">
            {{item}}
        </div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/service/service-tool.js"></script>
<script type="text/javascript" src="../../script/service/service-app.js"></script>
<script type="text/javascript" src="../../script/service/service-user.js"></script>
<script type="text/javascript" src="../../script/service/service-logic.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript">
    // html 的引号一律为双引号(""),js 为单引号('')
    var USER, $S, vm;
    apiready = function() {
        $S = SERVICE();
        USER = USER();
        console.log(JSON.stringify(api.pageParam) + '=====pageParam');

        fnInit();
    };
    // 初始化
    function fnInit() {
        vm = new Vue({
            el: '.vueApp',
            data: {
                info: null,
                listData: [],
                pageNo: 1,
                pageSize: 10
            }
        });
        getPageData();
    }

    function uploadImg() {
        // 要引入service-pic.js
        // 在APIready中执行fnInitAliYunOss();
        // 2 最大上传数量 uploadSuccess 上传完成后的监听
        fnUploadImg(2, 'uploadSuccess');
        // 此监听要放在APIready方法中，确保只监听一次
        api.addEventListener({
            name: 'uploadSuccess'
        }, function(ret) {
            // 拿到上传完成后的图片列表
            var imgs = ret.value.imgs;
            console.log(imgs);
        })
    }

    function load() {
        getPageData('headerRefreshing');
        fnAddHeaderRefreshingEvent(function() { //设置下拉刷新
            getPageData('headerRefreshing');
        });

        fnAddFooterLoadingEvent(function() { // 设置上拉加载
            getPageData('load');
        });

    }

    function getData() {
        var params = {};
        var url = '';
        var callback = function(data) {

        };
        POST(url, params, callback);
    }

    // 获取页面数据
    function getPageData(sign) {
        if(sign == 'headerRefreshing') {
            vm.pageNo = 1;
        } else {
            vm.pageNo ++;
        }
        var url = '';
        var params = {};
        var callback = function(data) {
            if(vm.pageNo == '1') {
                vm.listData = [];
            }
            var listData = data.listData;
            for(var i = 0; i < listData.length; i ++) {
                var item = listData[i];

            }
            vm.listData = vm.listData.concat(data.listData);
            // status 为200时,只返回data
        };
        var error = function(res) {
            // status 不是200时,全部返回
            api.refreshHeaderLoadDone();
        };
        POST(url, params, callback, error);
    }

    // 点击item
    function handleItem(item) {

    }
</script>
</html>
